﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DapperDal.DapperBase
{
    /// <summary>
    /// 所有DAL层的基类
    /// </summary>
    public abstract class DapperBaseDAL<TPrimary, TEntity> : DalBase<TEntity, TPrimary>, IDapperBaseDAL<TPrimary, TEntity>
        where TEntity : class, new()
    {

        #region 构造函数
        /// <summary>
        /// 使用指定的连接字符串
        /// </summary>
        /// <param name="connectionString"></param>
        public DapperBaseDAL(string connectionString) : base(connectionString)
        { }
        #endregion

        /// <summary>
        /// 新增一条数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public new TPrimary Insert(TEntity entity)
        {
            return base.Insert(entity);
        }

        /// <summary>
        /// 批量添加数据
        /// </summary>
        /// <param name="list"></param>
        public new void Insert(IEnumerable<TEntity> list)
        {
            base.Insert(list);
        }

        /// <summary>
        /// 根据主键取实体信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TEntity GetSingle(TPrimary id)
        {
            return base.Get(id);
        }

        /// <summary>
        /// 逻辑删除(软删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public abstract bool SoftDelete(TPrimary id);

        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public new bool Update(TEntity entity)
        {
            return base.Update(entity);
        }


    }
}
